package com.cy.src.myapplication;

import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import java.util.List;

public class RunningTaskInfoActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_running_task_info);
        runningTaskInfo(getApplication());
    }

    public void runningTaskInfo(Context context) {

        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {

            List<ActivityManager.RunningTaskInfo> runningTasks = activityManager.getRunningTasks(1);

            for (ActivityManager.RunningTaskInfo info : runningTasks) {
                String topName = info.topActivity.getClassName();
                Log.e("RunningTaskInfoActivity", "topName " + topName);
            }
        }
//        ActivityManager.RunningTaskInfo runningTaskInfo;
    }
}
